<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form name="addDataForm" id="addDataForm" method="post" action="/comm-dictionary-server/dictionaryManage/save">
	<table class="infoTable">
		<tbody>
		<tr>
			<th align="right" width="10%">父节点</th>
			<td><div id='pNameDiv'></div></input>
			</td>
		</tr>
		<tr>
			<th align="right" width="10%">字典名称</th>
			<td>
				<input id="pId" name="pId" type="hidden" >
				<input id="sysCodeValue" name="sysCode" type="hidden">
				<input type="hidden" id="id" name="id" >
				<input type="text" id="name" name="name" class="easyui-validatebox" style="width: 380px" maxlength="50" size="15" required="true"></input>
			</td>
		</tr>
		<tr>
			<th align="right" width="10%">字典值</th>
			<td><input type="text" id="value" name="value" class="easyui-validatebox" style="width: 380px" maxlength="50" size="15" required="true"></input>
			</td>
		</tr>
		<tr>
			<th align="right" width="10%">字典项说明</th>
			<td>
			<textarea rows="3" style="width: 380px;" id="remark" name="remark" onkeyup="checkLength('remarkError',50,'remark')"></textarea>
				<font color="red"><br />注：50个字符以内，还可以输入<span class="input_font" id="remarkError">50</span>个字符</font>
			</td>
		</tr>
		</tbody>
	</table>
</form>
<script type="text/javascript">
	$(function(){
		//从url中获取选中记录的id
		var id = getUrlParamValue("id");
		if(parentName==undefined) {
			parentName = '根节点';
		}
		$('#pNameDiv').html(parentName);
		//父节点id
		$('#pId').val($('#pIdDiv').val());
		var sysCodeValue = $('#sysCodeDiv').val();
		//系统编码sysCode
		$('#sysCodeValue').val(sysCodeValue);

		//回显选中的字典数据
		if (id!=undefined && id!=null && id!=''){
			$.ajax({
				type: "get",
				url:  '/comm-dictionary-server/dictionaryManage/findDictInfoById?id=' + id+'&sysCode='+$('#sysCodeDiv').val(),
				async : false,
				success: function(data,res){
					if (data.success) {
						var task = data.data;
						$('#name').val(task.name);
						$('#id').val(task.id);
						$('#value').val(task.value);
						$('#pId').val(task.pId);
						$('#remark').val(task.remark);
					}
				},
				error: function(res){
					alert("error")
					$.messager.alert('提示',i18n.requestError,'error');
				}
			});
		}
	});

	//从url获取指定参数的值
	function getUrlParamValue(paramName) {
		var obj=$("#firstLevelDialog").dialog('options'); //获取打开的dialog对象
		var url=obj["href"];
		var params = url.replace("?","?&").split("&");
		for(var i=1;i<params.length;i++) {
			if (params[i].indexOf(paramName+"=") == 0) {
				return params[i].substring((paramName+"=").length,params[i].length);
			}
		}
	}

	// $.getJSON('/comm-dictionary-server/dictionary/findDictionaryByParentValue?sysCode=common&parentValue=sys_code',function(jsonData){
	// $.getJSON('/comm-dictionary-server/dict/findDictionaryByIdOnly?id=',function(jsonData){
	// 	var id=$('#id').val();
	// 	if(id != undefined){
	// 		$.ajax({
	// 			type: "get",
	// 			url:  '/comm-schedule-server/task/getTask/' + selId,
	// 			async : false,
	// 			success: function(data,res){
	// 				if (data.success) {
	// 					var task = data.data;
	// 					$('#input_id').val(task.id);
	// 					$('#inputSysCodeCombobox').combobox('setValue',task.sysCode);
	// 					$('#inputTaskCodeText').val(task.code);
	// 					$('#inputTaskNameText').val(task.name);
	// 					$('#inputTaskConfText').val(task.conf);
	// 					$('#inputProceedMethodText').val(task.proceedMethod);
	// 					$('#remark').val(task.remark);
	// 				}
	// 			},
	// 			error: function(res){
	// 				$.messager.alert('提示',i18n.requestError,'error');
	// 			}
	// 		});
	// 	}
	// });
	

</script>